package mya_dc.shared_classes;

import java.io.Serializable;

/**
 * a Container for Compilation errors
 * 
 * @author      Adam Levi
 * <br>			MYA
 */
public class MyaCompilationError implements Comparable<MyaCompilationError>, Serializable
{
	private static final long serialVersionUID = -3029717614887268141L;
	
	/**
	 * Constructor
	 * 
	 * @param strFileName - The filename that associates to the error
	 * @param strLineNum  - The line number (represents as a string) where the error is located
	 * @param strError	  - The error information.
	 * 
	 */
	public MyaCompilationError(String strFileName, String strLineNum, String strError)
	{
		m_strFileName = strFileName;
		m_strLineNum = strLineNum;
		m_strError = strError;
	}
	
	@Override public String toString()
	{
		return m_strFileName + " : " + m_strLineNum + " : " + m_strError;
	}
	
	@Override public boolean equals(Object obj)
	{
		if (obj instanceof MyaCompilationError)
		{
			MyaCompilationError tmp = (MyaCompilationError)obj;
			return (this.m_strFileName == tmp.m_strFileName &&
					this.m_strError == tmp.m_strError &&
					this.m_strLineNum == tmp.m_strLineNum);
		}
		return false;
	}  
	public String m_strFileName;
	public String m_strLineNum;
	public String m_strError;
	@Override
	public int compareTo(MyaCompilationError o)
	{
		int tmp = this.m_strFileName.compareTo(o.m_strFileName);
		if (tmp != 0)
			return tmp;
		tmp = this.m_strLineNum.compareTo(o.m_strLineNum);
		if (tmp != 0)
			return tmp;
		return this.m_strError.compareTo(o.m_strError);
	}


}
